<template>
  <div class="StatisticalFreight">
    <el-card class="box-card">
      <div slot="header" class="clearfix">
        <span style="line-height: 36px;">统计支数报表</span>
      </div>
      <s-table
        :table="table"
        :expand="true"
        @http="tableWatch">
        <el-form-item slot="multiSelect" label="多选操作" prop="multiSelect" v-if="table.multiSelect">
          <el-row>
            <el-col :span="8">
              <el-button size="small" type="info" @click="tableExport('')">多选导出</el-button>
            </el-col>
          </el-row>
        </el-form-item>
        <!--<el-form-item label="统计支数名称" prop="mc">-->
          <!--<el-input type="text"-->
                    <!--class="input"-->
                    <!--v-model="autoVue_table_asnbh"-->
                    <!--placeholder="统计支数名称" spellcheck="false" aStatisticalFreightuto-capitalize="off" auto-complete="off"-->
                    <!--auto-correct="off"></el-input>-->
        <!--</el-form-item>-->
        <el-form-item label="状态查询" prop="state">
          <!--筛选条件-->
          <el-select  class="input"
                      v-model="state"
                      @change="query"
                      placeholder="请选择"
                      auto-complete="off"
                      auto-correct="off">
            <el-option label="全部" value="0" >
            </el-option>
            <el-option label="已发货订单" value="1">
            </el-option>
            <el-option label="待发货订单" value="2">
            </el-option>
          </el-select>
        </el-form-item>
      </s-table>
    </el-card>
  </div>
</template>

<script>
  import {AutoVue, AutoPromise, GetLodop, FormatterTime} from '~/plugins/Tools';
  import Config from '~/config';
  export default AutoVue({
    name: 'outOperation_check-FEcarWms',
    head: {
      'title': '统计支数',
      'meta': [
        {'hid': 'description', 'name': 'description', 'content': '乐速科技平台 统计支数 查看运费统计信息'},
      ],
    },
    store: ['USER'],
    data: {
      header: {
        'Content-Disposition': 'attachment',
      },
      table: {
        column: [
          /* {
            label: '发起部门',
            prop: 'fqbm',
            minWidth: '0px',
            search: false,
          },
          {
            label: '发起人',
            prop: 'fqr',
            minWidth: '0px',
            search: true,
          },
          {
            label: '用途',
            prop: 'yt',
            minWidth: '0px',
            search: false,
          }, */
        ],
        data: [ /* {
          hpbh: '20160502',
          hpmc: '王小虎',
          sl: '1518 弄',
          xbh: '1',
        } */ ],
        key: 'id',
        tableColumn: 0,
        url: '/ProvincialDynamicReportsController/Thenumberofshipmentsineach',
        total: 0,
        option: {
          page: 1,
          rows: 10,
          state: '',
        },
        summary: true,
      },
      state: '',
    },
    transition: 'slide-fade',
    methods: {
      async query () {
        this.table.option.state = this.state;
        this.tableWatch('table');
        this.table.option.state = '';
        if (this.table.option.rows >= 1 || this.table.option.page >= 1) {
          this.table.option.state = this.state;
          console.log('sdfsdfadf', this.table.option.state);
        }
      },
      tableExport (row) {
        let tableRef = 'table';
        let ids = [];
        if (row) {
          ids.push(row.Province);
        } else {
          this[tableRef].multipleSelection.forEach(item => {
            ids.push(item.Province);
          });
        }
        this.$confirm('您将导出统计支数报表。', '确认导出？', {
          confirmButtonText: '是',
          cancelButtonText: '否',
          type: 'warning',
        })
          .then(async _ => {
            try {
              let option = Object.assign({}, this['autoVue_' + tableRef]);
              await this.p({
                url: '/ProvincialDynamicReportsController/PmentSineachProvince',
                method: 'post',
                responseType: 'blob',
                data: {
                  ids,
                  state: this.state,
                  ...option,
                },
              });
            } catch (err) {
              console.log(err);
            }
          })
          .catch(_ => {
          });
      },
    },
    mounted: async function () {
      try {
        let headdata = await this.post('/WmsReportHeaderController/supportnumberhead', {
          page: 1,
          rows: 10,
        });
        this.table.tableColumn = headdata.contentList;
        this.table.tableColumnAll = headdata.contentList;
        this.state = '';
      } catch (err) {
        console.log(err);
      }
      this.tableWatch('table');
    },
  });
</script>
<style scoped lang="scss">
  .box-card {
    margin: 20px;
  }

  .createTimeSpan {
    display: block;
    margin-top: 34px;
  }

  @media screen and (max-width: 800px) {
    .createTimeSpan {
      margin-top: 0;
    }
    .box-card {
      margin: 0;
    }
  }

  .el-select {
    width: 100%;
  }
  .headertype {
    color:#1bab8b;
  }
</style>

<style lang="scss">

</style>
